<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<jsp:include   page="common/header.jsp" flush="true">
    <jsp:param name="title" value="权限分配" /> 
</jsp:include>
        <!-- 左侧 -->
       <jsp:include   page="common/left.jsp" flush="true"/>

        <!-- 右侧 -->	
        <div class="allot-page">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel">
                            <div class="panel-heading">
                                <div class="row">
                                    <span class="allot-heading-icon"></span>
                                    <span class="text">管理员权限分配</span>
                                </div>
                            </div>
                            <div class="panel-body">
                                <div class="panel-body-btn">
                                    <button id="button-add" type="button" class="btn btn-primary dropdown-toggle"
                                    	onclick="location='${basePath}/wxPrivilegeAction_findAll.action'">
                                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新建角色
                                    </button>
                                    <button id="button-add" type="button" class="btn btn-info dropdown-toggle"
                                    	onclick="location='${basePath}/wxPrivilegeAction_findAll_edit.action'">
                                        <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>查看/修改角色权限
                                    </button>
                                    <button id="button-bound" type="button" class="btn btn-danger">
                                        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>删除角色

                                    </button>
                                    <button id="button-refresh" type="button" class="btn btn-success" onclick="location='${basePath }/wxAdminAction_findAll.action'">
                                        <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>刷新信息
                                    </button>
                                </div>
                                <div class="row">
                                    <div class="col-lg-12">
                                        <div class="table-responsive">
                                            <form action="">
                                                <table class="table table-bordered table-hover">
                                                    <thead>
                                                        <tr>
                                                            <th>序号</th>
                                                            <th>用户姓名</th>
                                                            <th>角色名称</th>
                                                            <th>角色备注</th>
                                                            <th>操作</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    
                                                    <!-- 显示页面 -->
                                                    <c:forEach items="${wxAdminList }" var="wxAdmin" varStatus="status">
                                                   		<tr>
                                                            <td>${status.count } </td>
                                                            <td>${wxAdmin.truename } </td>
                                                            <td>${wxAdmin.wxRole.rolename } </td>
                                                            <td>${wxAdmin.wxRole.remark }</td>
                                                            <td>
                                                            <!-- 编辑按钮 -->
                                                         	    <a href="javascript:void(0)" class="allot-delete" >
                                                                <span class="glyphicon glyphicon-edit" aria-hidden="true" id="allot-edit" onclick="editRoleAndAdmin('${wxAdmin.id }','${wxAdmin.truename }','${wxAdmin.wxRole.id }','${wxAdmin.wxRole.rolename }')"></span>
                                                               </a>
<%--                                                                onclick="editRole('${wxAdmin.id }','${wxAdmin.truename }','${wxAdmin.wxRole.id }','${wxAdmin.wxRole.rolename }')" --%>
                                                            <!-- 编辑按钮 end-->
                                                            <!-- 删除按钮 -->
                                                            	<c:if test="${wxAdmin.roleid != 1 }">
                                                                <a href="javascript:void(0)" class="allot-delete" onclick='deleteRoleAndAdmin("${wxAdmin.id }")'>
                                                                	<span class="glyphicon glyphicon-remove-circle" aria-hidden="true" >
                                                                	</span>
                                                                </a>
                                              		     		</c:if>
                                                            <!-- 删除按钮 end -->
                                                            </td>
                                                        </tr>
                                                        </c:forEach>
                                                        <!-- ------------------ -->
<!--                                                         <tr> -->
<!--                                                             <td>001</td> -->
<!--                                                             <td>系统管理员</td> -->
<!--                                                             <td>系统管理员</td> -->
<!--                                                             <td> -->
<!--                                                                <a href="javascript:void(0)" class="allot-delete" onclick="editRole()"> -->
<!--                                                                 <span class="glyphicon glyphicon-edit" aria-hidden="true" id="allot-edit"></span> -->
<!--                                                                </a> -->
<!--                                                                 <a href="javascript:void(0)" class="allot-delete" onclick="deleteRole()"> -->
<!--                                                                 	<span class="glyphicon glyphicon-remove-circle" aria-hidden="true" > -->
<!--                                                                 	</span> -->
<!--                                                                 </a> -->
<!--                                                             </td> -->
<!--                                                         </tr> -->
                                                     <!-- 显示页面 end-->
                                                    </tbody>
                                                </table>
                                            </form>
                                            <!-- 分页条 -->
                                            <div class="page">
                                                <div class="left fl">
                                                    <a href="${basePath }/wxAdminAction_findAll.action?currentPage=1">首页</a>
													<c:forEach begin="1" end="${pageBean.totalPage }" varStatus="status">
														<c:if test="${status.count == pageBean.currentPage}">
                                                 		   <a href="${basePath }/wxAdminAction_findAll.action?currentPage=${status.count }" class="active">${status.count }</a>
														</c:if>
														<c:if test="${status.count != pageBean.currentPage}">
                                                 		   <a href="${basePath }/wxAdminAction_findAll.action?currentPage=${status.count }" >${status.count }</a>
														</c:if>
													</c:forEach>
													<c:if test="${pageBean.currentPage < pageBean.totalPage}">
                                                    <a href="${basePath }/wxAdminAction_findAll.action?currentPage=${pageBean.currentPage +1}">下一页</a>
                                                    </c:if>
													<c:if test="${pageBean.currentPage >= pageBean.totalPage}">
                                                    <a href="javascript:;">下一页</a>
                                                    </c:if>
                                                    
                                                    <a href="${basePath }/wxAdminAction_findAll.action?currentPage=${pageBean.totalPage }">尾页</a>
                                                    <input type="hidden" id="totalPage" value="${pageBean.totalPage }"> 
                                                    <span>跳至</span>
                                                    <input type="text" id="pageGO" />
                                                    <a href="javascript:;" id="paegLinkGo1">GO</a>
                                                </div>
                                                <div class="right fr">
                                                    <span class="now-num">当前第<b>${pageBean.currentPage }</b>页</span>
                                                    <span class="toggle-num">共<b>${pageBean.totalPage }</b>页</span>
                                                </div>
                                            </div>
                                            <!------------ 分页条 end------------>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
             <!-- 浮层 -->
        <div class="allot-bound-msk none">
            <div class="allot-bound-dialog">
                <div class="title">
                    <div class="left fl">
                        <span>删除角色</span>
                    </div>
                    <div class="right fr">
                        <a href="javascript:;" class="bound-msk-close"></a>
                    </div>
                </div>
                <div class="content">
                    <form action="">
                        <div class="bound-check-role">
                            <span>选择角色：</span>
                            <select name="delRole-roleid" id="delRole-roleid">
                            <c:forEach items="${wxWxRoleList }" var="wxWxRole">
                            	<option value="${wxWxRole.id }">${wxWxRole.rolename }</option>
                          	</c:forEach>
                            </select>
                        </div>
                        <a id="bound-info-save" href="javascript:;" class="bound-info-save" onclick="deleteRoleAndPrivilege()">提交</a>
                    </form>
                </div>
            </div>
		 <!-- 修改 -->
        <div class="allot-redact-msk none">
            <div class="allot-redact-dialog">
                <div class="title">
                    <div class="left fl">
                        <span>修改信息</span>
                    </div>
                    <div class="right fr">
                        <a href="javascript:;" class="redact-msk-close"></a>
                    </div>
                </div>
                <div class="content">
                    <form action="">
                        <div class="redact-check-user">
                            <span>用户名称：</span>
<%--                             <td>${wxAdmin.truename } </td> --%>
<%--                              <td>${wxAdmin.wxRole.rolename } </td> --%>
                            <input name="setRole-id" id="setRole-id" type="hidden" value=""/>
                            <input name="setRole-truename" id="setRole-truename" type="text" readonly unselectable="on"  value=""/>
                        </div>
                        <div class="redact-check-role" >
                            <span>用户角色：</span>
                            <select name="roleid" id="setRole-roleid" >
                            <c:forEach items="${wxWxRoleList }" var="wxWxRole">
                            	<option value="${wxWxRole.id }" >${wxWxRole.rolename }</option>
                          	</c:forEach>
                            </select>
                        </div>
                        <a id="redact-info-save" href="javascript:;" class="redact-info-save" onclick="updateRole()">提交</a>
                    </form>
                </div>
            </div>
        </div>      
        </div>  
                                    <!-- 底部 -->
<jsp:include   page="common/bottom.jsp" flush="true"/>
<script type="text/javascript" src="${basePath }/page/js/allot.js"></script>
<script type="text/javascript" src="${basePath }/page/js/role/role.js"></script>

    <script type="text/javascript">
       	$(document).on('click', '#paegLinkGo1', function() {
       		var page = $('#pageGO').val();
       		var totalPage = $('#totalPage').val()
       		if(page >0 && page <= totalPage){
       		window.location.href = "${basePath }/wxAdminAction_findAll.action?currentPage="+page;
       		}else{
       			return false;
       		}
       	})
       </script>